package summit.tests.tools
{

import flash.errors.IllegalOperationError;
	
public class TestHelpers
{
	public function TestHelpers()
	{
	}
	
	/** Returns an id provided by Basecamp in response headers.
	 * 
	 * <p>On successful <code>create</code> requests, Basecamp response
	 * with response headers that include the id of the record created.</p>
	 * 
	 * <p>This call will not work with milestones. Instead, look at the 
	 * <code>data</code> property on the <code>BasecampAPIEvent</code></p>.
	 * 
	 * @param responseHeaders The object provided with the APIEvent after a 
	 * successful call to create.
	 */
	public static function parseForIdFromResponseHeaders(
	responseHeaders:Object):String
	{
		var field:String = responseHeaders.Location;
		
		if(!field) throw new IllegalOperationError("No Location in Header");
		
		var regExp:RegExp = new RegExp("[0-9].*[0-9]"); // the new id
		var id:String = regExp.exec(field);
		
		return id;
	}
}
}